object Tip{
  import org.lxw.stock._
  val date=new java.text.SimpleDateFormat("yyyyMMdd").format(new java.util.Date)
  val stock_map=scala.collection.mutable.Map.empty[Stock,Int]
  val map=new MyMap((name:String)=>{
    val db=StockDB.db
    val aa=Diluted.flat(name,db.min5(name).takeRight(240/5*120).map(a=>Stock(a)).toSeq,date.toLong)
    Some(aa.toArray)
  })

  def ss_cci_map(t:(Min5Stock,Int,Int)) = if(t._1.index>=stock_map(t._1.array.stocks.head)) None else Some(t._1.cci(t._2,t._3))
  val cci_map=new MyMap(ss_cci_map)
  def getcci(min5Stock:Min5Stock,min:Int,ma:Int)=try{cci_map(min5Stock,min,ma)}catch{case e:NoSuchElementException=>min5Stock.cci(min,ma)}

  def ss_ma2_map(t:(Min5Stock,Int,Int)) =if(t._1.index>=stock_map(t._1.array.stocks.head)) None else Some(t._1.ma(t._2,t._3))
  val ma2_map=new MyMap(ss_ma2_map)
  def getma2(min5Stock:Min5Stock,min:Int,ma:Int)=try{ma2_map(min5Stock,min,ma)}catch{case e:NoSuchElementException=>min5Stock.ma(min,ma)}
  def update(id:String,ss:Seq[String]){
    val a=map(id)
     Min5Array((a ++ ss.map(a=>Stock(a)).filter(_.date>a.last.date)).toArray)
  }
}